<?php
/**
 * Created by PhpStorm.
 * User: User
 * Date: 2017/10/16
 * Time: 18:53
 */
class DB{
    static $obj=null;

    private function  __construct()
    {
        echo  "Mysql ......";
    }
     static  function getObj(){
        if(is_null(self::$obj)){
            self::$obj=new self();
        }
        return self::$obj;
    }
}
class Printer{
    static $obj=null;

    private function  __construct()
    {
        echo  "Mysql ......";
    }
    public static  function getInstance(){
        if(is_null(self::$obj)){
            self::$obj=new self();
        }
        return self::$obj;
    }
}
//var_dump(DB::getObj());
//echo "<br/>";
//var_dump(DB::getObj());
$p1=Printer::getInstance();
$p2=Printer::getInstance();
var_dump($p1);
echo "<br/>";
var_dump($p2);